package com.tcm.core.service;



import com.base.core.exception.ServiceException;
import com.tcm.core.domain.dto.DepartmentDTO;
import com.tcm.core.domain.vo.DepartmentVO;


import java.util.List;

public interface DepartmentService {

    /**
     * 获得一级子分类
     * @param parentId 父id
     * @return
     * @throws Exception
     */
    List<DepartmentVO> listSubDepartment(Long parentId) throws Exception;

    /**
     * 查询分类数据
     * @param id
     * @return
     */
    DepartmentVO findById(Long id);

    /**
     * 查询所有分类
     * @return
     */
    List<DepartmentVO> listDepartment() throws Exception;

    /**
     * 转换为树形结构
     * @return
     * @throws Exception
     */
    List<DepartmentVO> listToTree() throws Exception;


    /**
     * 递归查询子类
     * @param parentId 父类id
     * @param recursive
     * @return
     * @throws Exception
     */
    List<DepartmentVO> listSubDepartment(Long parentId, boolean recursive) throws Exception;

    /**
     * 加载所有父分类
     * @param categoryId
     * @return
     * @throws Exception
     */
    List<DepartmentVO> loadParents(Long categoryId) throws Exception;

    /**
     * 获取当前类别的所有父类别ID
     * @param categoryId
     * @return
     * @throws Exception
     */
    List<Long> listParentIds(Long categoryId) throws Exception;

    /**
     * 获得当前类别所有子类别ID
     * @param categoryId
     * @return
     * @throws Exception
     */
    List<Long> listChildIds(Long categoryId) throws Exception;

    /**
     * 验证分类有效性
     * @param categoryId
     * @return
     */
    DepartmentVO valid(Long categoryId);

    int create(DepartmentDTO departmentDTO) throws ServiceException;

    int update(DepartmentDTO departmentDTO);

    int deleteLogicById(Long id);
}
